<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue2.js"></script>
</head>
<body>
<!--
        监视器 ：  监听data中值的改变
-->
<div id="app">
    <p>姓:<input type="text" v-model="firstName"></p>
    <p>名:<input type="text" v-model="lastName"></p>
    <p>姓名:{{ fullName }}</p>
    <p>姓名:{{ full }}</p>
</div>

<script>
    let vm = new Vue({
        el: '#app',
        data: {
            firstName: "张",
            lastName: "三",
            fullName: "张三"
        },
        methods: {},
        computed:{
            full(){
                return this.firstName +this.lastName
            }
        },
        watch:{
            //  监听器   监听数据的改变
            firstName:function (newVal,OldVal){
                console.log("姓被修改了"+newVal+":"+OldVal)
                // this.fullName = this.firstName+this.lastName
                this.fullName = newVal+this.lastName
            },
            lastName(newVal,OldVal){
                console.log("名被修改了")
                this.fullName = this.firstName+newVal
            }
        }
    })
</script>

</body>
</html>